package com.sx.manage.controller.bank;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sx.manage.controller.base.MBaseController;
import com.sx.manage.service.bank.IMBaseBankService;
import com.sx.model.manage.mybatis.form.bank.MBankForm;
import com.sx.model.manage.mybatis.vo.bank.MBankVO;
import com.sx.model.manage.mybatis.vo.bank.MDropDownVO;
import com.sx.model.manage.mybatis.vo.result.ResultDropDownListVO;
import com.sx.model.manage.mybatis.vo.result.ResultObjectVO;
@Controller
@RequestMapping("/bankInfo")
public class MBankInfoController extends MBaseController{
	
	private Logger log = LoggerFactory.getLogger(this.getClass());
	@Resource(name="mBaseBankServiceImpl")
	private IMBaseBankService mBaseBankServiceImpl;
	
	@RequestMapping("/query_branch")
	@ResponseBody
	public ResultDropDownListVO<MDropDownVO> ajaxSerch(MBankForm form){
		log.info("查询支行信息form={}",form);
		if( StringUtils.isBlank(form.getChannel_type())){
			MDropDownVO downVO = new MDropDownVO();
			            downVO.setText("请选择开户渠道");
			List<MDropDownVO> list = new ArrayList<>();   
			list.add( downVO);
			log.info("开户渠道为空form={}",form);
			return  new ResultDropDownListVO<>(list,1,1,1);
		}
		return mBaseBankServiceImpl.queryBranchHuaXiaVO(form);
	}
	
	@RequestMapping("/bankInfo_byid/{id}")
	@ResponseBody
	public ResultObjectVO<MBankVO> query_bankInfo(MBankForm form){
		log.info("根据id支行信息form={}",form);
		return mBaseBankServiceImpl.query_bank(form);
	}

}
